<?php

  /*

      TravianWAP
      Copyright (c) 2007-08 by Ananas - All rights reserved
      http://n00bz.biz/travianwap/
      Contact: uroskn@gmail.com

      --------------------------------------------------------------------------

      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU  General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.

      You should have received a copy of the GNU  General Public License
      along with this program. If not, see http://www.gnu.org/licenses/.

  */

  define("MODULE_OK", 1);
  if (!defined("MAIN_UNIT")) die("h4xx0r");
  global $req;

  $queries = array(
    array('market',    '<td><a href="#" onClick="upd_res(1,1); return false;"><img class="res" src="img/un/r/1.gif"></a></td>'),
    array('train',     '<input type="Text" name="t'),
    array('mainbuild', MAIN_SELECT_REM),
    array('mainbuild', '</p><p><table width="100%" class="f10"><tr><td><a href="'),
    array('upgradet',  TROOP_UPGRADE_START),
    array('upgradet',  '<td width="6%" rowspan="2" valign="top" class="s7"><img class="unit" src="img/un/u/'),
    array('rally_p',   '<a href="a2b.php">')
  );
  
  $rid = "id";
  $requested_gid = False;
  if (!empty($req["gid"]))
  {
    $req["id"] = htmlspecialchars($req["gid"]);
    $rid = "gid";
    $requested_gid = True;
  }
  $tmp = http_get("http://{$_SESSION["serv"]}/build.php?$rid={$req["id"]}");
  $text = $tmp["body"];
  
  printtop($text);
  
  $ok = False;
  foreach($queries as $key => $value)
  {
    if (strpos($text, $value[1]) != False)
    {
      $ok = True;
      include("modules/details_modules/{$value[0]}.php");
      break;
    }
  }
  if (($ok == False) && (empty($req["stfu"]))) echo "<b>No details available</b><br/><br/>";
